package com.ymatou.iapi.sellerquery.testcase;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.seller.trading.api.parameter.Convertor;
import com.ymatou.query.seller.trading.api.parameter.ExportOrderInfo;
import com.ymatou.query.seller.trading.api.parameter.ExportSellerOrderInfosBean;
import com.ymatou.query.seller.trading.api.parameter.ExportSellerOrderInfosResponse;
import com.ymatou.query.seller.trading.api.parameter.GetExportOrderInfoResult;
import com.ymatou.query.seller.trading.api.parameter.SellerExportOrderQueryModel;
import com.ymatou.query.seller.trading.api.parameter.SellerExportedOrderInfo;
import com.ymatou.query.seller.trading.api.parameter.Sp_GetExportOrderInfoByOrderIds_v1;
import com.ymatou.query.seller.trading.api.parameter.TimeRange;
import com.ymatou.query.seller.trading.api.parameter.Ymt_O_OrderNote;
import com.ymatou.query.seller.trading.api.parameter.Ymt_Order;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderInfo;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderState;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderSummary;
import com.ymatou.query.trading.api.parameter.GetExportOrderInfo;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

/**
 * @date 2016-06-28
 * @author songyefeng
 * @desc 分批导出卖家订单信息
 */
@TestSuite
public class Ts_ExportSellerOrderInfos {

	private static ExportSellerOrderInfosBean exportSellerOrderInfosBean;
	private static com.ymatou.query.seller.trading.api.service.ExportSellerOrderInfosCall exportSellerOrderInfosCall;
//	private static com.ymatou.iapi.trading.sellerquery.service.ExportSellerOrderInfosCall exportSellerOrderInfosCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分批导出卖家订单信息");
	}

	@Before
	public void caseUp() {
		exportSellerOrderInfosBean = new ExportSellerOrderInfosBean();
		exportSellerOrderInfosCall = new com.ymatou.query.seller.trading.api.service.ExportSellerOrderInfosCall();
//		exportSellerOrderInfosCall = new com.ymatou.iapi.trading.sellerquery.service.ExportSellerOrderInfosCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(exportSellerOrderInfosCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verify() {
		ExportSellerOrderInfosResponse expectedResponse = new ExportSellerOrderInfosResponse();
		ConstructExpectedResponse(expectedResponse);
		ExportSellerOrderInfosResponse actualResponse = exportSellerOrderInfosCall
				.getExportSellerOrderInfosResponse();
		DataUtil.verifyEquals(expectedResponse
				.getSellerExportedPartialOrderInfos().size(), actualResponse
				.getSellerExportedPartialOrderInfos().size(),
				"验证SellerExportedPartialOrderInfos的订单数量");
		if (DataUtil.isNullOrEmpty(expectedResponse
				.getSellerExportedPartialOrderInfos()) == false) {
			List<SellerExportedOrderInfo> expects = expectedResponse
					.getSellerExportedPartialOrderInfos();
			for (SellerExportedOrderInfo actual : actualResponse
					.getSellerExportedPartialOrderInfos()) {
				boolean exists = expects.stream().anyMatch(
						x -> x.getOrderNo() == actual.getOrderNo());
				DataUtil.verifyEquals(true, exists,
						"验证orderno:" + actual.getOrderNo() + "是否存在");
				if (exists) {
					SellerExportedOrderInfo expect = expects.stream()
							.filter(x -> x.getOrderNo() == actual.getOrderNo())
							.collect(Collectors.toList()).get(0);
					DataUtil.verifyEquals(expect.getAddress(),
							actual.getAddress(),
							"验证orderno:" + actual.getOrderNo() + "的Address");
					DataUtil.verifyDateEquals(expect.getAddTime(),
							actual.getAddTime(),
							"验证orderno:" + actual.getOrderNo() + "的AddTime");
					DataUtil.verifyDateEquals(expect.getApplyPostPayTime(),
							actual.getApplyPostPayTime(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ApplyPostPayTime");
					DataUtil.verifyEquals(expect.getBondedArea(),
							actual.getBondedArea(),
							"验证orderno:" + actual.getOrderNo() + "的BondedArea");
					DataUtil.verifyEquals(expect.getBuyerLoginId(),
							actual.getBuyerLoginId(),
							"验证orderno:" + actual.getOrderNo()
									+ "的BuyerLoginId");
					DataUtil.verifyDecimalEquals(expect.getCashAmount(),
							actual.getCashAmount(),
							"验证orderno:" + actual.getOrderNo() + "的CashAmount");
//					DataUtil.verifyEquals(expect.getCatalogInfos(),
//							actual.getCatalogInfos(),
//							"验证orderno:" + actual.getOrderNo()
//									+ "的CatalogInfos");
//					DataUtil.verifyEquals(expect.getCatalogStatus(),
//							actual.getCatalogStatus(),
//							"验证orderno:" + actual.getOrderNo()
//									+ "的CatalogStatus");
					DataUtil.verifyEquals(expect.getCatalogType(),
							actual.getCatalogType(),
							"验证orderno:" + actual.getOrderNo() + "的CatalogType");
//					DataUtil.verifyEquals(expect.getDeliveryType(),
//							actual.getDeliveryType(),
//							"验证orderno:" + actual.getOrderNo()
//									+ "的DeliveryType");
					DataUtil.verifyDecimalEquals(expect.getDepositAmount(),
							actual.getDepositAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的DepositAmount");
					DataUtil.verifyDateEquals(expect.getDispathTime(),
							actual.getDispathTime(),
							"验证orderno:" + actual.getOrderNo() + "的DispathTime");
					DataUtil.verifyDecimalEquals(expect.getFreight(),
							actual.getFreight(),
							"验证orderno:" + actual.getOrderNo() + "的Freight");
					DataUtil.verifyEquals(expect.getIsPaidInFull(),
							actual.getIsPaidInFull(),
							"验证orderno:" + actual.getOrderNo()
									+ "的IsPaidInFull");
					DataUtil.verifyEquals(expect.getLeaveWord(),
							actual.getLeaveWord(),
							"验证orderno:" + actual.getOrderNo() + "的LeaveWord");
//					DataUtil.verifyEquals(expect.getLogisticsCode(),
//							actual.getLogisticsCode(),
//							"验证orderno:" + actual.getOrderNo()
//									+ "的LogisticsCode");
					DataUtil.verifyEquals(true,
							actual.getLogisticsCode()!=null,
							"验证orderno:" + actual.getOrderNo()
									+ "的LogisticsCode");
//					DataUtil.verifyEquals(expect.getLogisticsCompany(),
//							actual.getLogisticsCompany(),
//							"验证orderno:" + actual.getOrderNo()
//									+ "的LogisticsCompany");
					DataUtil.verifyEquals(true,
							actual.getLogisticsCompany() != null,
							"验证orderno:" + actual.getOrderNo()
									+ "的LogisticsCompany");
					DataUtil.verifyEquals(expect.getOrderNote(),
							actual.getOrderNote(),
							"验证orderno:" + actual.getOrderNo() + "的OrderNote");
					DataUtil.verifyEquals(expect.getOrderState(),
							actual.getOrderState(),
							"验证orderno:" + actual.getOrderNo() + "的OrderState");
//					DataUtil.verifyEquals(expect.getOrderType(),
//							actual.getOrderType(),
//							"验证orderno:" + actual.getOrderNo() + "的OrderType");
					DataUtil.verifyEquals(
							expect.getPackageDelivery_DomesticDelivered(),
							actual.getPackageDelivery_DomesticDelivered(),
							"验证orderno:" + actual.getOrderNo()
									+ "的PackageDelivery_DomesticDelivered");
					DataUtil.verifyDateEquals(expect.getPayTime(),
							actual.getPayTime(),
							"验证orderno:" + actual.getOrderNo() + "的PayTime");
					DataUtil.verifyEquals(expect.getPhone(), actual.getPhone(),
							"验证orderno:" + actual.getOrderNo() + "的Phone");
					DataUtil.verifyEquals(expect.getPostCode(),
							actual.getPostCode(),
							"验证orderno:" + actual.getOrderNo() + "的PostCode");
					DataUtil.verifyDecimalEquals(expect.getPostPayAmount(),
							actual.getPostPayAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的PostPayAmount");
					DataUtil.verifyDateEquals(expect.getPostPayTime(),
							actual.getPostPayTime(),
							"验证orderno:" + actual.getOrderNo() + "的PostPayTime");
					DataUtil.verifyEquals(expect.getProductNames(),
							actual.getProductNames(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ProductNames");
					DataUtil.verifyEquals(expect.getProductNos(),
							actual.getProductNos(),
							"验证orderno:" + actual.getOrderNo() + "的ProductNos");
					DataUtil.verifyEquals(expect.getProductNum(),
							actual.getProductNum(),
							"验证orderno:" + actual.getOrderNo() + "的ProductNum");
					DataUtil.verifyEquals(expect.getProductPrice(),
							actual.getProductPrice(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ProductPrice");
					DataUtil.verifyEquals(expect.getReceivePerson(),
							actual.getReceivePerson(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ReceivePerson");
					DataUtil.verifyDecimalEquals(expect.getRefundAmount(),
							actual.getRefundAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的RefundAmount");
					DataUtil.verifyEquals(expect.getRemarkLevel(),
							actual.getRemarkLevel(),
							"验证orderno:" + actual.getOrderNo() + "的RemarkLevel");
					DataUtil.verifyEquals(expect.getRiskVerifiedStatus(),
							actual.getRiskVerifiedStatus(), "验证orderno:"
									+ actual.getOrderNo()
									+ "的RiskVerifiedStatus");
					DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
							.GetValueOrDefault(expect.getSellerCouponAmount()),
							actual.getSellerCouponAmount(), "验证orderno:"
									+ actual.getOrderNo()
									+ "的SellerCouponAmount");
					DataUtil.verifyEquals(expect.getTelephone(),
							actual.getTelephone(),
							"验证orderno:" + actual.getOrderNo() + "的Telephone");
					DataUtil.verifyDecimalEquals(expect.getTotalAmount(),
							actual.getTotalAmount(),
							"验证orderno:" + actual.getOrderNo() + "的TotalAmount");
				}
			}
		}
	}

	private void ConstructExpectedResponse(
			ExportSellerOrderInfosResponse response) {
		Process(response);
	}

	private void Process(ExportSellerOrderInfosResponse response) {
		SellerExportOrderQueryModel model = Convertor
				.SellerExportOrderRequestArguments(exportSellerOrderInfosBean);
		ExportSellerOrderInfosResponseProcessor(model, response);
	}

	@SuppressWarnings("rawtypes")
	private void ExportSellerOrderInfosResponseProcessor(
			SellerExportOrderQueryModel model,
			ExportSellerOrderInfosResponse response) {
		Sp_GetExportOrderInfoByOrderIds_v1 sp = ExportOrderInfo
				.GetExportSellerOrderInfoListSqlCommand(model);
		List<Map> orders = sp.getOrders();
		List<Map> orderInfos = sp.getOrderInfos();
		List<Map> orderNotes = sp.getOrderNotes();
		List<Map> orderStates = sp.getOrderStates();
		List<Map> orderSummaries = sp.getOrderSummarys();
		GetExportOrderInfoResult result = ConvertResult(orders, orderInfos,
				orderNotes, orderStates, orderSummaries);
		if (DataUtil.isNullOrEmpty(result.getOrders())) {
			response.setSellerExportedPartialOrderInfos(new ArrayList<SellerExportedOrderInfo>());
			response.setNextPartitionKey(null);
			return;
		}
		String nextPartitionKey = result.getOrders().size() < ExportOrderInfo.MAX_PER_QUERY_COUNT ? null
				: String.valueOf(result.getOrders().stream()
						.min((a, b) -> a.getiOrderId() - b.getiOrderId()).get()
						.getiOrderId());
		response.setNextPartitionKey(nextPartitionKey);
		response.setSellerExportedPartialOrderInfos(GetExportOrderInfo
				.GetExportOrderInfos(result));
	}

	@SuppressWarnings("rawtypes")
	private GetExportOrderInfoResult ConvertResult(List<Map> orders,
			List<Map> orderInfos, List<Map> orderNotes, List<Map> orderStates,
			List<Map> orderSummaries) {
		GetExportOrderInfoResult result = new GetExportOrderInfoResult();
		List<Ymt_Order> Orders = new ArrayList<Ymt_Order>();
		List<Ymt_OrderInfo> OrderInfos = new ArrayList<Ymt_OrderInfo>();
		List<Ymt_O_OrderNote> OrderNotes = new ArrayList<Ymt_O_OrderNote>();
		List<Ymt_OrderState> OrderStates = new ArrayList<Ymt_OrderState>();
		List<Ymt_OrderSummary> OrderSummaries = new ArrayList<Ymt_OrderSummary>();
		if (false == DataUtil.isNullOrEmpty(orders)) {
			for (Map m : orders) {
				Ymt_Order order = new Ymt_Order();
				DataUtil.mapToBean(order, m);
				Orders.add(order);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderInfos)) {
			for (Map map : orderInfos) {
				Ymt_OrderInfo oi = new Ymt_OrderInfo();
				DataUtil.mapToBean(oi, map);
				OrderInfos.add(oi);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderNotes)) {
			for (Map map : orderNotes) {
				Ymt_O_OrderNote note = new Ymt_O_OrderNote();
				DataUtil.mapToBean(note, map);
				OrderNotes.add(note);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderStates)) {
			for (Map map : orderStates) {
				Ymt_OrderState state = new Ymt_OrderState();
				DataUtil.mapToBean(state, map);
				OrderStates.add(state);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderSummaries)) {
			for (Map map : orderSummaries) {
				Ymt_OrderSummary summary = new Ymt_OrderSummary();
				DataUtil.mapToBean(summary, map);
				OrderSummaries.add(summary);
			}
		}
		result.setOrders(Orders);
		result.setOrderInfos(OrderInfos);
		result.setOrderNotes(OrderNotes);
		result.setOrderStates(OrderStates);
		result.setOrderSummaries(OrderSummaries);
		return result;
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_001() {
		Logger.start(true, "分批导出卖家订单信息");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-1));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0));
			exportSellerOrderInfosBean.setPaidTime(paidTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_002() {
		Logger.start(true, "分批导出卖家订单信息, 测试paidTime筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setPaidTime(paidTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_003() {
		Logger.start(true, "分批导出卖家订单信息, 测试订单状态为17的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.SellerAccept.getValue());
			exportSellerOrderInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setPaidTime(paidTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_004() {
		Logger.start(true, "分批导出卖家订单信息, paidTime的end为空");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderPostPay.getValue());
			exportSellerOrderInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-10));
			exportSellerOrderInfosBean.setPaidTime(paidTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_005() {
		Logger.start(true, "分批导出卖家订单信息, paidTime的start为空");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderPostPay.getValue());
			exportSellerOrderInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerOrderInfosBean.setPaidTime(paidTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_006() {
		Logger.start(true, "分批导出卖家订单信息, 测试订单状态为101的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderPostPay.getValue());
			exportSellerOrderInfosBean.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setPaidTime(paidTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_007() {
		Logger.start(true, "分批导出卖家订单信息, 测试BuyerNickName的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			exportSellerOrderInfosBean.setBuyerNickName("est007");
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_008() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setCreatedTime(createdTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_009() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerOrderInfosBean.setCreatedTime(createdTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_010() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setCreatedTime(createdTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_011() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setDeliveredTime(deliveredTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_012() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerOrderInfosBean.setDeliveredTime(deliveredTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_013() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean.setDeliveredTime(deliveredTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_014() {
		Logger.start(true, "分批导出卖家订单信息, 测试LogisticsTypes的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> logisticsTypes = new ArrayList<Integer>();
			logisticsTypes
					.add(LogisticsTypeEnum.XloboBondedDelivery.getValue());
			exportSellerOrderInfosBean.setLogisticsTypes(logisticsTypes);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_015() {
		Logger.start(true, "分批导出卖家订单信息, 测试OrderId的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			exportSellerOrderInfosBean.setOrderId(105836235);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_016() {
		Logger.start(true, "分批导出卖家订单信息, 测试OrderId的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.AccountPaid.getValue());
			orderStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			exportSellerOrderInfosBean.setOrderStatus(orderStatus);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_017() {
		Logger.start(true, "分批导出卖家订单信息, 测试PayTypes的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			List<Integer> payTypes = new ArrayList<Integer>();
			payTypes.add(0);
			payTypes.add(2);
			exportSellerOrderInfosBean.setPayTypes(payTypes);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_018() {
		Logger.start(true,"分批导出卖家订单信息, 测试PostpayAppliedTime的筛选(ymt_orders.dApplyPostPayTime),begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange postpayAppliedTime = new TimeRange();
			postpayAppliedTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			postpayAppliedTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-2));
			exportSellerOrderInfosBean
					.setPostpayAppliedTime(postpayAppliedTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_019() {
		Logger.start(true,"分批导出卖家订单信息, 测试PostpayAppliedTime的筛选(ymt_orders.dApplyPostPayTime),只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange postpayAppliedTime = new TimeRange();
			postpayAppliedTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerOrderInfosBean
					.setPostpayAppliedTime(postpayAppliedTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_020() {
		Logger.start(true,"分批导出卖家订单信息, 测试PostpayAppliedTime的筛选(ymt_orders.dApplyPostPayTime),只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			TimeRange postpayAppliedTime = new TimeRange();
			postpayAppliedTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-3));
			exportSellerOrderInfosBean
					.setPostpayAppliedTime(postpayAppliedTime);
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_021() {
		Logger.start(true, "分批导出卖家订单信息, 测试ProductName的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			exportSellerOrderInfosBean.setSellerId(SellerId);
			exportSellerOrderInfosBean.setProductName("接口自动化测试Test");
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_023() {
		Logger.start(true, "分批导出卖家订单信息失败, SellerId为null");
		try {
			exportSellerOrderInfosBean.setSellerId(null);
			exportSellerOrderInfosBean.setProductName("接口自动化测试Test");
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("400", exportSellerOrderInfosCall.getCode(),
					"验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_024() {
		Logger.start(true, "分批导出卖家订单信息失败, SellerId为0");
		try {
			exportSellerOrderInfosBean.setSellerId(0);
			exportSellerOrderInfosBean.setProductName("接口自动化测试Test");
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("400", exportSellerOrderInfosCall.getCode(),
					"验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_025() {
		Logger.start(true, "分批导出卖家订单信息失败, SellerId不存在");
		try {
			exportSellerOrderInfosBean.setSellerId(404);
			exportSellerOrderInfosBean.setProductName("接口自动化测试Test");
			exportSellerOrderInfosCall.setData(exportSellerOrderInfosBean);
			exportSellerOrderInfosCall.callService();
			Logger.verifyEquals("200", exportSellerOrderInfosCall.getCode(),
					"验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}